package com.example.manager.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.manager.entity.CourseSelection;
import com.example.manager.service.CourseSelectionService;

@RestController
public class CourseSelectionController {
	
	@Autowired
	private CourseSelectionService service;
	
	@GetMapping("courseSelection")
	public List<CourseSelection> getAllCourseSelection(){
		return service.findAll();
	}
	
	@GetMapping("courseSelectionBySid/{sid}")
	public List<CourseSelection> getBySid(@PathVariable String sid) {
		return service.getByStudent(sid);
	}
	
	@GetMapping("courseSelectionByCTId/{id}")
	public List<CourseSelection> getByCourseTeachingId(@PathVariable Integer id) {
		return service.getByCourseTeachingId(id);
	}
	
	@GetMapping("courseSelectionById/{id}")
	public CourseSelection getById(@PathVariable Integer id) {
		return service.getById(id);
	}
	
	@PostMapping("courseSelection")
	public String selectCourse(String sid, Integer courseTeachingId) {
		return service.selectCourse(sid, courseTeachingId);
	}
	
	@DeleteMapping("courseSelection/{id}")
	public String cancelSelectCourse(@PathVariable Integer id) {
		return service.cancelSelectCourse(id);
	}
	
}
